from common.base_page import BasePage
from appium.webdriver.common.appiumby import AppiumBy
from time import sleep


class Unfollow(BasePage):
    # 点击头像
    headSculpture_loc = (AppiumBy.ID, 'com.jhss.youguu:id/head_pic')
    # 点击关注
    follow_loc = (AppiumBy.XPATH, '//android.widget.TextView[@text="关注"]')
    # 点击取消
    cancellation_loc = (AppiumBy.ID, 'com.jhss.youguu:id/commontAttText')
    # 返回
    back_loc = (AppiumBy.XPATH, '//android.widget.ImageButton[@bounds="[24,48][70,138]"]')
    # 获取关注数
    followNum_loc = (AppiumBy.ID, 'com.jhss.youguu:id/tv_focus_num')

    # 取消关注执行
    def unfollow(self):
        # 点击头像
        self.click_ele(self.headSculpture_loc)
        sleep(3)
        # 点击关注
        self.click_ele(self.follow_loc)
        sleep(2)
        # 点击取消
        self.click_ele(self.cancellation_loc)
        sleep(5)
        # 返回
        self.click_ele(self.back_loc)
        # 下滑刷新页面1次
        self.swip_down(1)
        sleep(3)
